module App::View
    class Settings < Qt::Widget
        attr_reader :hide_older_than, :textedit
        attr_reader :buttonbox
        attr_reader :ignored_clients, :pushbutton_add, :pushbutton_del

        def initialize()
            super()

            layout = Qt::VBoxLayout.new

            grid = Qt::GridLayout.new
            grid.addWidget Qt::Label.new("Hide tasks older than"), 0, 0
            @hide_older_than = Qt::SpinBox.new {
                setValue $model.tree.toggl.hide_older_than
                setMinimum 0
                setSuffix " day(s)"
            }
            grid.addWidget @hide_older_than, 0, 1

            layout.addLayout grid

            @textedit = Qt::TextEdit.new {
                self.auto_formatting = self.class.AutoNone
                self.accept_rich_text = false
                #self.html = false
                self.plain_text = $model.dropwin_style
            }
            layout.addWidget @textedit

            @ignored_clients = Qt::ListView.new {
                self.set_model $widget.model.ignored_clients
            }
            layout.addWidget @ignored_clients
            @pushbutton_add = Qt::PushButton.new "Add"
            @pushbutton_del = Qt::PushButton.new "Del"
            layout.addWidget @pushbutton_add
            layout.addWidget @pushbutton_del

            @buttonbox = Qt::DialogButtonBox.new
            @buttonbox.addButton Qt::DialogButtonBox::Ok
            @buttonbox.addButton Qt::DialogButtonBox::Apply
            @buttonbox.addButton Qt::DialogButtonBox::Cancel
            layout.addWidget @buttonbox

            setLayout layout

            show
        end
    end
end
